import { createRouter,createWebHistory, type RouteRecordRaw } from "vue-router";
import ThreeCh1 from "@/components/ThreeCh1.vue";
import ThreeCh2 from "@/components/ThreeCh2.vue";
import Menu from "@/components/Menu.vue";
import ThreeCh3 from "@/components/ThreeCh3.vue";
import ThreeCh4 from "@/components/ThreeCh4.vue";
import ThreeCh5 from "@/components/ThreeCh5.vue";
import ThreeCh6 from "@/components/ThreeCh6.vue";
import ThreeCh7 from "@/components/ThreeCh7.vue";
import ThreeCh8 from "@/components/ThreeCh8.vue";
import ThreeCh9 from "@/components/ThreeCh9.vue";
import ThreeCh10 from "@/components/ThreeCh10.vue";
import ThreeCh11 from "@/components/ThreeCh11.vue";
import ThreeCh12 from "@/components/ThreeCh12.vue";
import ThreeCh13 from "@/components/ThreeCh13.vue";
import ThreeCh14 from "@/components/ThreeCh14.vue";
import ThreeCh15 from "@/components/ThreeCh15.vue";
import ThreeCh16 from "@/components/ThreeCh16.vue";
import ThreeCh17 from "@/components/ThreeCh17.vue";
import ThreeCh18 from "@/components/ThreeCh18.vue";
import ThreeCh19 from "@/components/ThreeCh19.vue";
import ThreeCh20 from "@/components/ThreeCh20.vue";
import ThreeCh21 from "@/components/ThreeCh21.vue";
import ThreeCh22 from "@/components/ThreeCh22.vue";
import ThreeCh23 from "@/components/ThreeCh23.vue";
import ThreeCh24 from "@/components/ThreeCh24.vue";
import ThreeCh25 from "@/components/ThreeCh25.vue";
import ThreeCh26 from "@/components/ThreeCh26.vue";
import ThreeCh27 from "@/components/ThreeCh27.vue";
import ThreeCh28 from "@/components/ThreeCh28.vue";

const routes: RouteRecordRaw[] = [
  { path: "/", 
    component: Menu,
    name: "menu",
    beforeEnter: (_to, _from, next) => {
        // 检查权限等
        // if (hasPermission()) {
        //   next()
        // } else {
        //   next('/login')
        // }
        next()
      }
   },
   { path: "/threeCh1", name: "完整示例",component: ThreeCh1 },
  { path: "/threeCh2", name: "WebGL是否可用",component: ThreeCh2 },
  { path: "/threeCh3", name: "绘制一条线",component: ThreeCh3 },
  { path: "/threeCh4", name: "绘制文本",component: ThreeCh4 },
  { path: "/threeCh5", name: "加载gltf",component: ThreeCh5 },
  { path: "/threeCh6", name: "基本图元",component: ThreeCh6 },
  { path: "/threeCh7", name: "场景图",component: ThreeCh7 },
  { path: "/threeCh8", name: "坦克",component: ThreeCh8 },
  { path: "/threeCh9", name: "自己仿照的场景图",component: ThreeCh9 },
  { path: "/threeCh10", name: "材质",component: ThreeCh10 },
  { path: "/threeCh11", name: "纹理",component: ThreeCh11 },
  { path: "/threeCh12", name: "纹理参数",component: ThreeCh12 },
  { path: "/threeCh13", name: "光照-环境光",component: ThreeCh13 },
  { path: "/threeCh14", name: "光照-半球光",component: ThreeCh14 },
  { path: "/threeCh15", name: "光照-方向光",component: ThreeCh15 },
  { path: "/threeCh16", name: "光照-点光源",component: ThreeCh16 },
  { path: "/threeCh17", name: "光照-聚光灯",component: ThreeCh17 },
  { path: "/threeCh18", name: "光照-矩形光",component: ThreeCh18 },
  { path: "/threeCh19", name: "摄像机",component: ThreeCh19 },
  { path: "/threeCh20", name: "阴影",component: ThreeCh20 },
  { path: "/threeCh21", name: "正经阴影",component: ThreeCh21 },
  { path: "/threeCh22", name: "雾",component: ThreeCh22 },
  { path: "/threeCh23", name: "渲染目标",component: ThreeCh23 },
  { path: "/threeCh24", name: "自定义几何体",component: ThreeCh24 },
  { path: "/threeCh25", name: "自定义几何体1",component: ThreeCh25 },
  { path: "/threeCh26", name: "按需渲染",component: ThreeCh26 },
  { path: "/threeCh27", name: "实时调试展示",component: ThreeCh27 },
  { path: "/threeCh28", name: "展示FPS",component: ThreeCh28 },
];

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes
  })
  

// 全局前置守卫
router.beforeEach((to, from, next) => {
    console.log('即将从', from.path, '导航到', to.path)
    // 可以在这里做权限检查等
    next() // 一定要调用 next()
})

// 全局后置守卫
router.afterEach((to, from) => {
    console.log('已经从', from.path, '导航到', to.path) 
})


export default router
